<?php
 if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Class Payment extends MY_Controller
{
    public function __construct()
    {
        parent::__construct();
        //$this->checkAdmin($this->session->userdata('admin_id'));
        $this->data['controller'] = 'payment';         
        $this->load->model('Mpayment');
    }
    
   public function chargincard()
    {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('codeCard', 'Mã thẻ cào', 'required');
        $this->form_validation->set_rules('serieCard', 'Serial thẻ cào', 'required');
        $this->form_validation->set_rules('typeCard', 'Loại thẻ', 'required');
        
        if($this->form_validation->run() === TRUE)
        {
            $run = $this->Mpayment->chargincardDB($this->session->userdata('user_id')); 
            if($run == 200)
            {
                $this->data['result'] = 'Nạp thẻ thành công';
            }else{
                $this->data['result'] = $run;
            }
        }
        
        $this->data['action'] = 'chargincard';
        $this->load->view('template/layout', $this->data);
    }
    
    public function chargingsms()
    {
        die(json_encode($this->Mpayment->chargingSMS()));
    }
}


